package com.abc.robot01.activity.compose

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import com.abc.robot01.activity.MYBLUE
import com.abc.robot01.activity.mysp
import com.abc.robot01.activity.px

class ButtonDemo : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            val scrollState = rememberScrollState()
            Column(
                modifier = Modifier
                    .padding(start = 10.dp, top = 10.dp)
                    .verticalScroll(scrollState)
                    .fillMaxSize(),
            ) {
                com.abc.robot01.activity.MyOutLineText(
                    text = "渲染成功", size = DpSize(105.px, 36.px),
                    textColor = Color(0xFF266FE8),
                    fontSize = 20.mysp,
                    disabledContainerColor = Color.White, shape = RoundedCornerShape(6.px),
                    border = BorderStroke(2.px, MYBLUE.copy(alpha = 0.2f))
                )

            }
        }
    }
}

@Composable
fun OutlinedButtonExample(onClick: () -> Unit) {
    OutlinedButton(onClick = { onClick() },
        modifier = Modifier
            .size(105.px, 36.px),
        contentPadding= PaddingValues(0.px),
        border = BorderStroke(
            width = 2.px, color = Color.Gray // 自定义边框厚度和颜色
        )
        ) {
        Text(
            text = "渲染失败",
            style = MaterialTheme.typography.bodyMedium.copy(
                fontSize = 20.mysp,
                fontWeight = FontWeight.Normal
            ),
            color = Color.Red
        )
    }
}

@Composable
fun MyButton01() {
    Button(onClick = {  }) {
        repeat(10){
            Text(text = "$it")
            Spacer(modifier = Modifier.width(20.px))
        }
    }
}













